
[dbo].[aspnet_Profile_DeleteInactiveProfiles]
SET ANSI_NULLS OFF
GO
CREATE PROCEDURE dbo.aspnet_Profile_DeleteInactiveProfiles
@ApplicationName nvarchar(256),
@ProfileAuthOptions int,
@InactiveSinceDate datetime
AS
BEGIN
DECLARE @ApplicationId uniqueidentifier
SELECT @ApplicationId = NULL
SELECT @ApplicationId = ApplicationId FROM aspnet_Applications WHERE LOWER(@ApplicationName) = LoweredApplicationName
IF (@ApplicationId IS NULL)
BEGIN
SELECT 0
RETURN
END
DELETE
FROM dbo.aspnet_Profile
WHERE UserId IN
( SELECT UserId
FROM dbo.aspnet_Users u
WHERE ApplicationId = @ApplicationId
AND (LastActivityDate <= @InactiveSinceDate)
AND (
(@ProfileAuthOptions = 2)
OR (@ProfileAuthOptions = 0 AND IsAnonymous = 1)
OR (@ProfileAuthOptions = 1 AND IsAnonymous = 0)
)
)
SELECT @@ROWCOUNT
END
GO
GRANT EXECUTE ON [dbo].[aspnet_Profile_DeleteInactiveProfiles] TO [aspnet_Profile_FullAccess]
GO